package com.david.warehouse.mapper;

import com.david.system.pojo.Entity.WhType;
import com.david.warehouse.pojo.entity.InboundDetail;
import com.david.warehouse.pojo.entity.InboundOrder;
import com.david.warehouse.pojo.entity.InboundVO;
import com.david.warehouse.pojo.entity.Inventory;
import com.david.warehouse.pojo.vo.OutboundVO;
import com.david.warehouse.pojo.vo.InventorySearchVO;
import com.david.warehouse.pojo.vo.InventoryVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface InventoryMapper {
    List<InventoryVO> selectInventoryList(@Param("searchVO") InventorySearchVO searchVO,@Param("isAll") Boolean isAll);

    InventoryVO selectInventoryById(Integer id);

    List<InboundVO> selectInboundListByProductIdWhId(Integer productId, Integer whId);

    List<OutboundVO> selectOutboundListByProductIdWhId(Integer productId, Integer whId);

    @Insert("insert into whm_inbound_order (batch_no, type_id, vendor_id, wh_id, remark, attach, create_user_id, create_time) " +
            "VALUES (#{batchNo}, #{typeId}, #{vendorId}, #{whId}, #{remark}, #{attach}, #{createUserId}, #{createTime}) ")
    void insertInboundOrder(InboundOrder inboundOrder);

    void insertInboundDetailList(List<InboundDetail> inboundDetailList);

    @Select("select id, name, code from whm_wh_type where id = #{typeId}")
    WhType selectWhTypeById(Integer typeId);

    List<InboundOrder> selectInboundOrderByOrderAndCreatetime(@Param("inboundOrder") InboundOrder inboundOrder, List<LocalDateTime> createTimeRange);

    InboundOrder selectInboundOrder(InboundOrder inboundOrder);

    List<InboundDetail> selectInboundDetailByBatchNo(String batchNo);

    Inventory selectInventory(Inventory inventory);

    void updateInventory(Inventory inventory);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    Inventory insertInventory(Inventory inventory);
}
